package test3.parser;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Aug 2, 2007
 * Time: 11:00:12 AM
 * Revision: 0
 */
public class Token
{
    public static final int TYPE_UNKNOWN = -1;
    public static final int TYPE_END_OF_FILE = 0;

    public static final int TYPE_STR_COMMENT = 1;
    public static final int TYPE_STR_IDENTIFIER = 2;
    public static final int TYPE_STR_NUMBER = 3;
    public static final int TYPE_STR_STRING = 4;
    public static final int TYPE_STR_CHAR = 5;

    public static final int TYPE_CH_DOT = 10;
    public static final int TYPE_CH_COMMA = 11;
    public static final int TYPE_CH_LCURL = 12;
    public static final int TYPE_CH_RCURL = 13;
    public static final int TYPE_CH_LBRACE = 14;
    public static final int TYPE_CH_RBRACE = 15;
    public static final int TYPE_CH_LPARAN = 16;
    public static final int TYPE_CH_RPARAN = 17;

    public static final int TYPE_OP_ADD = 20;
    public static final int TYPE_OP_SUB = 21;
    public static final int TYPE_OP_MUL = 22;
    public static final int TYPE_OP_DIV = 23;
    public static final int TYPE_OP_MOD = 24;

    public static final int TYPE_OP_ADDE = 30;
    public static final int TYPE_OP_SUBE = 31;
    public static final int TYPE_OP_MULE = 32;
    public static final int TYPE_OP_DIVE = 33;
    public static final int TYPE_OP_MODE = 34;

    private int type;
    private int startPos;
    private int endPos;

    private String error;

    private TokenManager manager;

    public Token(TokenManager manager)
    {
        this.manager = manager; 
    }

    public String getText()
    {
        return manager.getText(startPos, endPos);
    }
    public int getType()
    {
        return type;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    public int getStartPos()
    {
        return startPos;
    }

    public void setStartPos(int startPos)
    {
        this.startPos = startPos;
    }

    public int getEndPos()
    {
        return endPos;
    }

    public void setEndPos(int endPos)
    {
        this.endPos = endPos;
    }

    public void setBounds(int startPos, int endPos)
    {
        this.startPos = startPos;
        this.endPos = endPos;
    }

    public String getError()
    {
        return error;
    }

    public void setError(String error)
    {
        this.error = error;
    }
}
